﻿
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.util.*" %>
<%@ page import="com.lmpop.trade.ti_news.*" %>

<%!
	public boolean isExistCookie(HttpServletRequest request,String info_id){
		Cookie   cookies[]=request.getCookies();
		Cookie   sCookie=null;
		String   svalue=null;
		String   sname=null;
		boolean isExist = false;
		if(cookies!=null && cookies.length>0){
		   for(int a=0;a<cookies.length;a++){
				String name = cookies[a].getName();
				String value = cookies[a].getValue();
				if(!name.equals("") && name.equals(info_id)){
					isExist = true;
				}
		   }
		}
		return isExist;
	}
%>

<%
	String click_num = "0";
	Ti_newsInfo newsInfo = new Ti_newsInfo();
	String info_id = "";
	if(request.getParameter("info_id")!=null && !request.getParameter("info_id").equals("")){
			info_id = request.getParameter("info_id");
		}
	if(!isExistCookie(request,info_id)){
		newsInfo.updateNewsClickNum(info_id);
			Cookie cookie = new Cookie(info_id, info_id);
			cookie.setMaxAge(60*60*24*3);
			cookie.setPath("/");
			response.addCookie(cookie);
	}
	
	click_num = newsInfo.getNewsClickNum(info_id);
	out.print(click_num);
%>